package com.example.myapplication.kotlin

fun main() {
    var p1 = person()
    p1.name = "zhangsan"
    p1.age = 18
    p1.eat()

    var p2 = person()
    p1.name = "zhangsi"
    p1.age = 19
    p1.eat()
}

class person {
    var name: String = " "
    var age: Int = 0
    fun eat() {
        println("姓名: $name, 年龄: $age")
    }
}

//fun main() {
//    // 实例化
////    var dog = Dog()
////    dog.name = "旺财"
////    dog.friend = "小花"
////    dog.eat("骨头")
////    dog.bark()
////    println(dog.name + dog.friend)
////
////    // 实例化cat
////    var cat = Cat("三花猫", "罗非鱼", 99)
////    cat.eat()
////    cat.
//
//    // 如果有次构造函数，可以通过多种不同的形式进行实例化
//    val p = Person("小王")
//    val p2 = Person("小王", 18)
//    val p3 = Person("小王", 18, "中国")
//}
//
//class Dog {
//    var name: String = ""
//    var friend: String = ""
//    fun eat(food: String) {
//        println(food + "好好吃")
//    }
//
//    fun bark() {
//        println("旺旺~~")
//    }
//}

//class Person constructor(var name: String) {
//    var age: Int = 0
//    var country: String = ""
//
//    constructor(name: String, age: Int) : this(name) {
//        this.age = age
//    }
//
//    constructor(name: String, age: Int, country: String) : this(name, age) {
//        this.country = country
//    }
//}